angular.module('mamApp').controller('planController', ['$scope', 'PlayControlManager', '$state', 'ImsDialog',
    function ($scope, PlayControlManager, $state, ImsDialog) {


        $scope.search = {
            pageNo: $state.params.pageNo || 1,
            pageSize: $state.params.pageSize || 10
        };


        $scope.paginationConf = {
            currentPage: $state.params.pageNo || 1,
            itemsPerPage: $state.params.pageSize || 10,
            pagesLength: 9,
            search: 0,
            onChange: function () {
                $scope.search.pageNo = this.currentPage;
                $scope.search.pageSize = this.itemsPerPage;
                $state.go($state.current.name, $scope.search)
            }
        }
        $scope.noPermission=false;
        PlayControlManager.albumPlanList([$scope.search.pageNo, $scope.search.pageSize]).then(function (result) {
            if(result.data.c=='n'){
                $scope.noPermission=true;
            }else{
                $scope.noPermission=false;
                $scope.planList = result.data.pageList;
                $scope.paginationConf.totalItems = result.data.total;
            }

        })

        $scope.delete = function (id) {
            ImsDialog.open({title:"删除确认",message:"您确定要删除该方案吗?"}).then(function (a) {
                if(a=="ok"){
                    PlayControlManager.albumPlanDelete(id).then(function (result) {
                        if (result.data.c == "s") {
                            $state.reload();
                        }

                    })
                }
            })


        }


    }])

